Attribute VB_Name = "ModAddressBarText"
Option Explicit
Public Enum BP_BUFFERFORMAT
BPBF_COMPATIBLEBITMAP = 0
BPBF_DIB = 1
BPBF_TOPDOWNDIB = 2
BPBF_TOPDOWNMONODIB = 3
End Enum
Public Declare Function BeginBufferedPaint Lib "uxtheme.dll" (ByVal hdcTarget As Long, _
pRectarget As Long, ByVal dwFormat As BP_BUFFERFORMAT, ByVal pPaintParams As Long, pHDC As Long) As Long
Public Declare Function EndBufferedPaint Lib "uxtheme.dll" (ByVal hBufferedPaint As Long, _
ByVal fUpdataTarget As Long) As Long
Public Declare Function BufferedPaintSetAlpha Lib "uxtheme.dll" (ByVal hBufferedPaint As Long, _
prc As Long, ByVal Alpha As Long) As Long     'prc AS Rect, both are right
Public Declare Function BufferedPaintRenderAnimation Lib "uxtheme.dll" (ByVal hWnd As Long, ByVal hdcTarget As Long) As Long
'===============init & uninit functions===================
Public Declare Function BufferedPaintInit Lib "uxtheme.dll" () As Long
Public Declare Function BufferedPaintUnInit Lib "uxtheme.dll" () As Long
'the two function above returns S_OK if successful.
Public Const S_OK = 0
'================================================
Private pHDC As Long
Private pFont As Long
Private Handle As Long
Private Rect2 As RECT
Private hBrush As Long, hBrushOld As Long
Private hFontOld As Long

Public Function ExExtTextOutW(ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal wOptions As Long, lpRect As Long, ByVal lpString As Long, ByVal nCount As Long, lpDx As Long) As Long
BufferedPaintInit

Handle = BeginBufferedPaint(hdc, lpRect, BPBF_TOPDOWNDIB, 0, ByVal VarPtr(pHDC))

CopyMemory Rect2, lpRect, 16

BitBlt pHDC, Rect2.Left, Rect2.Top, Rect2.Right - Rect2.Left, Rect2.Bottom - Rect2.Top, hdc, Rect2.Left, Rect2.Top, SRCCOPY

pFont = GetCurrentObject(hdc, OBJ_FONT)
hFontOld = SelectObject(pHDC, pFont)

SetBkMode pHDC, GetBkMode(hdc)
SetBkColor pHDC, GetBkColor(hdc)
SetTextColor pHDC, GetTextColor(hdc)

ExtTextOutW pHDC, x, y, wOptions, lpRect, lpString, nCount, lpDx
BufferedPaintSetAlpha Handle, lpRect, &HFF

SelectObject pHDC, hFontOld

EndBufferedPaint Handle, 1

BufferedPaintUnInit
End Function

